#!/bin/bash

cd /etc/pam.d
for i in *
do
    if [ "$i" != "passwd" ]; then
        x=`grep -q ^"auth    required    /lib/security/pam_hsc.so" $i`
        if [ $? -eq 1 ]; then
            echo "auth    required    /lib/security/pam_hsc.so" >> $i
        fi
    fi
done
cd /
grep -q "HMC_BASH_PROFILE_PROCESSING" /etc/profile
if [ $? -ne 0 ]; then
    if [ -f /opt/hsc/data/ssh/hmcbashprofile ]; then
        mv /etc/profile /etc/profile.tmp
        cp /opt/hsc/data/ssh/hmcbashprofile /etc/profile
        cat /etc/profile.tmp >> /etc/profile
    fi
fi
x=`grep "^*backarrowKeyIsErase:" /usr/X11R6/lib/X11/app-defaults/XTerm 2>/dev/null`
if [ $? -eq 0 ]; then
    y=`echo $x | cut -d' ' -f2`
    if [ "$y" = "true" ]; then
        sed -e 's/^*backarrowKeyIsErase:[ \t]true/*backarrowKeyIsErase:\tfalse/g' /usr/X11R6/lib/X11/app-defaults/XTerm > /tmp/_saved_XTerm
        if [ $? -eq 0 ]; then
            mv /tmp/_saved_XTerm /usr/X11R6/lib/X11/app-defaults/XTerm
        fi
    fi
else
    echo "*backarrowKeyIsErase:\tfalse" >> /usr/X11R6/lib/X11/app-defaults/XTerm
fi
# Enable ctrl-alt-del if not already enabled
grep -q "^# ca::ctrlaltdel" /etc/inittab
if [ $? -eq 0 ]; then
   sed -e 's/^# ca::ctrlaltdel/ca::ctrlaltdel/g' /etc/inittab > /tmp/__inittab__
   if [ $? -eq 0 ]; then
      mv /tmp/__inittab__ /etc/inittab
   fi
fi
if [ -f /hmcrbin/more ]; then
  rm -f /hmcrbin/more
fi
if [ -f /usr/hmcrbin/less ]; then
  rm -f /usr/hmcrbin/less
fi
if [ -f /usr/hmcrbin/awk ]; then
  rm -f /usr/hmcrbin/awk
fi

/usr/sbin/rsct/bin/rmcctrl -q
/sbin/chkconfig -d -f ipsec     2>&1 >/dev/null
/sbin/chkconfig -d -f ldap      2>&1 >/dev/null
/sbin/chkconfig -d -f named     2>&1 >/dev/null
/sbin/chkconfig -d -f nfs       2>&1 >/dev/null
/sbin/chkconfig -d -f nfslock   2>&1 >/dev/null
/sbin/chkconfig -d -f nfsserver 2>&1 >/dev/null
/sbin/chkconfig -d -f nscd      2>&1 >/dev/null
/sbin/chkconfig -d -f portmap   2>&1 >/dev/null
/sbin/chkconfig -d -f rpasswdd  2>&1 >/dev/null
/sbin/chkconfig -d -f setserial 2>&1 >/dev/null
/sbin/chkconfig -d -f slurpd    2>&1 >/dev/null
/sbin/chkconfig -d -f xfs       2>&1 >/dev/null

/usr/bin/chage -M 99999 root    2>&1 >/dev/null
/usr/bin/chage -M 99999 hscroot 2>&1 >/dev/null
/usr/bin/chage -M 99999 ccfw    2>&1 >/dev/null
/usr/websm/bin/wsmserver -enable -portstart 30000 -portend 30009
if [ -f /etc/dhcpd.conf ]
then
  /usr/bin/sed -e 's/^max-lease-time[ ]*7200/max-lease-time infinite/g' /etc/dhcpd.conf > /tmp/_new_dhcpd.conf
  mv /tmp/_new_dhcpd.conf /etc/dhcpd.conf
fi
